﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data; 

namespace MyHotel_DAO
{
    public abstract class DAO
    {
        //protected abstract object createObjectFromDatarow(DataRow row);
        //protected List<object> getListObjectFromDataTable(DataTable dt)
        //{
        //    List<object> list = new List<object>();
        //    for (int i = 0; i < dt.Rows.Count; i++)
        //    {
        //        object obj = createObjectFromDatarow(dt.Rows[i]);
        //        list.Add(obj);
        //    }
        //    return list; 
        //}

        protected abstract object createObjectFromDatarow(DataRow row);

        protected List<T> getListFromDataTable<T>(DataTable dt)
        {
            List<T> list = new List<T>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                T t = (T)createObjectFromDatarow(dt.Rows[i]);
                list.Add(t);
            }
            return list;
        }
    }
}
